/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.cezary.butler.walili.server.config;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.lang.ref.Reference;
import java.util.Properties;
import java.util.logging.Level;
import pl.cezary.butler.walili.common.config.Configuration;



/**
 *
 * @author Czarek
 */
public class ServerConfiguration extends Configuration {
    
    
    private static ServerConfiguration INSTANCE = new ServerConfiguration();
    
    public static ServerConfiguration getInstance(){
        return INSTANCE;
    }
    
    private volatile Long result_limit;
    private volatile Long limit_resolution;
    private volatile Integer max_priority;

    public Integer getMaxPriority() {
        if (max_priority == null) {
            max_priority = Integer.valueOf(prop.getProperty("max_priority"));
        }
        return max_priority;
    }

    @Override
    protected void clearFetched() {
        super.clearFetched();
        result_limit = null;
        limit_resolution = null;
        max_priority = null;
    }
    

    public String getDbServer() {
        return prop.getProperty("db_server");
    }

    public String getDbName() {
        return prop.getProperty("db_name");
    }

    public String getDbLogin() {
        return prop.getProperty("db_login");
    }

    public String getDbPassword() {
        return prop.getProperty("db_password");
    }

    public String getDbType() {
        return prop.getProperty("db_type");
    }

    public String getDbFile() {
        return prop.getProperty("db_file");
    }

    public Long getUserResultLimit() {
        if (result_limit == null) {
            result_limit = Long.valueOf(prop.getProperty("user_result_limit"));
        }
        return result_limit;
    }                

    public Long getUserLimitResolution() {
        if (limit_resolution == null) {
            limit_resolution = Long.valueOf(prop.getProperty("user_limit_resolution")) * 1000;
        }
        return limit_resolution;
    }
    
}
